using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ItemCoverageExceptMap : EntityTypeConfiguration<ItemCoverageExcept>
    {
        public ItemCoverageExceptMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.ItemId)
                .IsRequired()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("ItemCoverageExcept");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.CoverageId).HasColumnName("CoverageId");
            this.Property(t => t.ItemId).HasColumnName("ItemId");
            this.Property(t => t.Percentage).HasColumnName("Percentage");
            this.Property(t => t.TypeId).HasColumnName("TypeId");
            this.Property(t => t.CategoryId).HasColumnName("CategoryId");
            this.Property(t => t.deductible).HasColumnName("deductible");
            this.Property(t => t.deductibleFlag).HasColumnName("deductibleFlag");
            this.Property(t => t.ICE_CoPay).HasColumnName("ICE_CoPay");
            this.Property(t => t.ICE_Authorization).HasColumnName("ICE_Authorization");

            // Relationships
            this.HasRequired(t => t.CoveragePlan)
                .WithMany(t => t.ItemCoverageExcepts)
                .HasForeignKey(d => d.CoverageId);
            this.HasRequired(t => t.Item)
                .WithMany(t => t.ItemCoverageExcepts)
                .HasForeignKey(d => d.ItemId);

        }
    }
}
